package com.fupan.Works;


import com.rabbitmq.client.Channel;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.io.IOException;


@Component
@RabbitListener(queues = "worksQueue")
public class WorksConsumerB {   //监听队列，自动接收消息
    @RabbitHandler
    public void onMsg(String msg , Channel channel, Message message) throws IOException {
        System.out.println("WorksConsumerB : "+msg);

        //手动Ack
        channel.basicAck(message.getMessageProperties().getDeliveryTag(),false);
        //multiple：是否批量
        // .true:将一次性ack所有小于deliveryTag的消息
        // .false，只ack当前消息
    }
}